<?php
    require_once("../includes/common.inc.php");

    set_time_limit(0);
    $allInfo = RssInfoManager::GetAllSourceInfo();
    $options = get_option('rss_pckr_option');
    $maxPostsCount = $options['max_posts_per_resource'];
    $maxPostsTotal = $options['max_posts_per_fetch'];
    $rssSpider = new RssSpider($maxPostsCount, $maxPostsTotal);
    foreach ($allInfo as $sourceInfo)
    {
        if ($rssSpider->GetFetchedPostsCount() >= $maxPostsTotal)
        {
            break;
        }
        $rssInfo = $rssSpider->RetrieveFeed($sourceInfo);
        if ($rssInfo)
        {
            RssInfoManager::Save($rssInfo);
        }
    }

    echo "1";